package work20241128;

import java.util.Arrays;

/**
 * @author zdl
 * @date 2024/11/28
 */
public class Demo5 {
    public static void main(String[] args) {
        //写一个方法 用于合并两个int类型的数组
        int[] arr = {1,2,5,8,9};
        int[] arr1 = {1,3,0};
        int[] newArr = test(arr,arr1);
        System.out.println(Arrays.toString(newArr));
    }
    public static int[] test(int[] arr,int[] arr1){
        int[] newArr = new int[arr.length+ arr1.length];
        int index= 0;
        for (int i = 0; i < arr.length; i++) {
            newArr[index++] = arr[i];
        }
        for (int i = 0; i < arr1.length; i++) {
            newArr[index++] = arr1[i];
        }
        return newArr;
    }
}
